package com.wgo.bpot.server.web.filter;

import org.apache.log4j.Logger;

/**
 * A servlet filter that provides a thread-bound session-per-request.
 * <p>
 * This filter should be used if your <tt>hibernate.current_session_context_class</tt>
 * configuration is set to <tt>thread</tt> and you are not using JTA/CMT. You can use
 * this filter for a thread-bound <tt>Session</tt>, either with resource-local transactions
 * (direct JDBC) or user-managed JTA transactions. Set your
 * <tt>hibernate.transaction.factory_class</tt> accordingly.
 * <p>
 * An alternative, more flexible solution is <tt>TransactionInterceptor</tt>
 * that can be applied to any pointcut with JBoss AOP.
 * <p>
 * Note that you should not use this interceptor out-of-the-box with enabled optimistic
 * concurrency control. Apply your own compensation logic for failed conversations, this
 * is totally dependent on your applications design.
 *
 * @see org.hibernate.ce.auction.persistence.TransactionInterceptor
 *
 */
public class SimpleHibernateThreadFilter extends HibernateThreadFilter {

	private static Logger log = Logger.getLogger(SimpleHibernateThreadFilter.class);

	protected void postServlet() {
		// Commit and cleanup
		log.debug("Rolling back the database transaction");
		sf.getCurrentSession().getTransaction().rollback();
	}


}